Rewritten main and wrapper scripts to JS.