fix headers and missing functions for MSVC/MinGW