cleanup and structure refactoring