Add a small validation assert to catch a rare bug
Fix compilation on recent cygwin
Fix confusion between -n and -d switches in main