Mac compatibility fixes

Note: sys.platform should be darwin for mac, but not linux, unless StackOverflow lied to me. os.name is posix for both.