added misc refactoring