Fixed several small JS bugs