Ported to compile on Xcode 5.1.1 with Clang (instead of good old GCC).  Fixed most warnings.