Added RAII to SpikeSort class.

Also fixed rare conditions in which a unit ID is not properly
initialized, which led to saved sorted units with negative ID numbers.