Fix errors preventing compilation

Just some minor bug fixes.