Simple event loop implementation
Small changes and cleanup