Fixed portability issues