Some portability fixes, working towards win32 compatibility