Moving some code to extension methods.