Fixes for Win: min/max macros, unistd.h includes

Added workarounds for Windows min/max global macros. Covered by #ifdef
WIN32 includes of unistd.h