small fix on memory cleaning