Removes the horrible protofactory code in favor of something more elegant.