Update to cosmic ray removal with restructuring to make generalization easier