fixed some bugs causing errors in firefox