Move JS to external file, and a few other adjustments.