Fixed some JavaScript problems