Cleaned up some messy javascript
Merge pull request #273 from msalsbery/bad-code-fix

Cleaned up some messy javascript