Update code to make it compile on Mac OS X 10.9 and use c++11 compiler flags