Fixed a few bugs, changed scopes
Lots of modifications for events