Fixed several minor bugs.