Adjust the factory to make it compatible with the latest changes in other branches.