Memory management

Clean up some mistakes from last submission.