Fix some portability issues