levelbag optimization
cleanup and refactoring (does not affecct functionality)