Revert "memory cleanup"

This reverts commit 30fa54f7008c617fd4e3a9561edc2bfd58f7f2d0.