Changed the events system into an extendable framework.