Fixed a few js bugs
merged changes from master