Several refactors