Do some light refactoring