More refactoring

Maybe getting a bit too clever for our own good now.