Fixed some more bugs in the JS part