Restructured factory method.