Moving some common logic to a trait.