moved the type factory stuff to its own library