general cleaning and refactorging