Updated implementation to be more trait-based.