add polyfill for addEventListener
Add some util functions, formatting changes