Investors & landlords

Let me make sure I get the numbers right... 

So the rental portion for the realtor fee would be 42k*0.75=31.5k. 

Home portion: 42k*0.25=10.5k. 

So, to calculate the amount we need to put towards a 1031 exchange, would it be like this: 525k (rental portion sales price)-300k(rental portion purchase price)-31.5k (realtor fee rental portion)= 193.5k? Is this the amount we would need to exchange? 

For the primary residence tax free gain, we would have: 175k (sales price)-100k (purchase) - 10.5k (realtor fees) = 64.5k. 

 

Now, the total amount we would technically keep is 700k-42k (realtor fees)-350k mortgage = 308k. Assuming we are putting the 193.5k towards a 1031 exchange, and the 64.5k is tax free cash from the primary, what happens to the remaining 50k? Is it also tax free cash? Because we have 308k-193k-64.5k=50k that we haven't accounted for.