added threading and more refactoring to event.rb