Bring in support for event binding

Also, this commit refactors some functions to no longer be part of the
prototype chain.