cleanup and refactoring...