made progress on the event loop, but there is still a wierd timing issue.