Fixed JS bugs