cleaned up JS functionality

Lots of pair programming clean up going on here!