Refactor some factories