fix some bugs (onload)

added windows.onload
other minor fixes