Fix memory errors.