Added memory cleanup.