Add changes to Factory dealloc.

Add chenges to Factory dealloc.