Major event loop rewrite