Fixed memory issues in lab7