Changes from Adam for compiling on Mac OSX