Fixed several small Javascript bugs.