cleanup after refactoring, fixing some minor bugs