refactor the event system, add lots of tweaks