bugixes and more

Changed the way registerEvent is called. Fixed a lot of bugs and some other stuff I can't remember