Residence and capital gains