Fixing several minor bugs.