Restructure JS

Opening this PR early for discussion