Added memory de-initialization function.