Update code so it runs on OS X