first phase of major refactor on javascript
intermediate push of eric rewrite after eclipse freaked out