Portability fixes, merge in abstract branch