Took care of some memory management