Original transaction:
Input: 4.99 BTC from Alice's address(es) to 1someaddress
Output: 4.99 BTC to 1someaddress (= Bob)
Stuck in limbo, would need 0.01 BTC fee likely.
New transaction:
Input: 4.99 BTC from 1someaddress and 0.01 from either 1someaddress (ideally) or another address under the control of Bob to 1someaddress or another of his addresses
Output: 4.99 BTC to 1someaddress (= Bob) or another of his addresses (he could also just output 4.98 BTC and spend the 0.01 on miner fees)
Net fee: 0.01 BTC to miner
The miner then includes both to get the fee on the second, which is only valid if the first one went through. It is either possible to let fewer BTC arrive at 1someaddress and paying the differnece to miners or to have the 4.99 BTC arrive at 1someaddress and pay the miners from existing other funds.
^^^
Is the above correct or did you only implement the case where fewer BTC than planned arrive at the address in the end?