Added some improvements to the javascript events.