Refactored events stuff

I needed to do this to internally manage firebase events, and prevent multiple firebase events from being triggered at once.
The style of implicit type casting is hard to read IMO.