more cleaning, some refactoring