cleanup and refactoring (does not affecct functionality)