insertScriptLoader and related improvements