Merged initial fixes for Cygwin compilation