split factory.hpp/re-templatize