Fixed JS bug and some minor issues