Cleaned up some messy javascript

...to sleep better.

Yes, addEvent and removeEvent now do what they always did - initialize themselves appropriately at runtime.  The old TODO comments were incorrect.