Feature/jstidyup

Did some tidying up of the JS. Will close #39.