Tweak code to hopefully be robust on a Mac