I think we need a bigger hammer on this PR. I think we must go for a bigger clean up here. This code is terrible and it's not so difficult to make it simple. Let me know, I can give it a try on Monday if you prefer.  