I read through all the code and understand what the previous problem were and why this will solve the problem.
I think we should left a TODO or warning here. 

This pull request looks good to me except the comment stuff.