Clean singularity code a bit.