some portability improvements