Do some refactoring.