A few Mac and Linux compatibility fixes