Cleaned up event loop a bit