fixed some minor bugs after refactoring