Do some refactors