file cleanup and refactoring