fixed the js errors and cleaned up the code; fixes #19
Merge branch 'js_errors' into gh-pages