Fixed minor bugs created by the last refactoring.