Do some refactorings