Fixing JS bugs