more js fixes and code cleanup
Merge pull request #64 from kurund/js-fixes

more js fixes and code cleanup