Further factor out templated parts