a few portability fixes