fix mac handling, thanks to Kestutis Kupciunas