Made external loading of js scripts more efficient. Added some debugging console.log statements