A little styling but mostly JS refactoring.
been a while, not sure what this commit does