fixed some portability issues