Corrections made for porting to mac