Bugfix: adding event handlers before window.onload