fixed some portability issues between mac and linux