Large cleanup of DSP code