As the codebase becomes bigger this is a time to restructure and model the code the right way.
Before, it was just an unstructured unorganized mess. I delayed this as far as I could because its really boring to recode this stuff but no more.
So now we have a nice little engine class, frame buffer, proper event mechanism, input manager and other nice stuff.