Portability fixes