Add event listener functions
Various additions
Change JSON typeclass to use toJSON