Fix and improve Cygwin support