More main loop overhaul.