Fixing few js bugs