more refactoring/cleanup