Moved template factory to its own namespace