Fix some memory errors.