Fix logic, Instantiation of Factory

This is related to php-io issue.