Rewrote resource loader to elimintate use of the window object
merge improvements from piratecargo