Fix Javascript bugs that arose during refactoring.