Simplified the main event loop.

This is the main source of memory usage, and the main bottleneck for
speed, so hopefully we should see a speed increase.

My tests show a speed increase of roughly 20%