Fixed some memory stuff