Deductions & credits

One more question:

Suppose I refi this mixed used mortgage loan.  Say at the time of refi of the above example, there is a balance of $450k left on the loan, $150k home acquisition debt (the same as when I took out the first mixed-use mortgage) and $300k of home equity debt used for rental property acquisition (paid $50k of principle).  But I refi the loan secured by my principle residence for $400k and contribute $50k of cash from my personal account (i keep separate accounts and books) to pay down my $150k home acqusition debt.  can I now allocate for the refi $100k of home acqusition debt and $300k of home equity debt?  Or does the IRS consider a refi the same loan and apply all principle reductions including prepayments to reducing home equity debt first?  If the latter, it means that I can never reduce home acquistion debt until the home equity debt is paid off, even if new loans are taken.