Fixed some memory errors.