Does some refactoring