Improve diffraction spectrum code, some changes