completed javascript
cleanup and few fixes