minor fixes, add singularity detection