Move JS to separate include file
Complete rewrite