Refactor singularity generator.'