Do some refactorings.