Clean up extraneous code

Basically what the commit title says. Created wrapper functions for promises and events and pass everything through these. Also cleaned up some unnecessary stuff.