Fixed some bugs in JS occuring in firefox