Fixed code to work on OSX and Ubuntu.