some renaming and refactoring