a few portability improvements for gcc