added memory fixes for ghostfactory