Memory cleaning through unsetting of variables at the end of loops