Small tweaks and added a polyfill to enable custom events in stupid IE