Refactored CreateObject in anticipation of using unique_ptr