Compile on Mac OS X, fix warnings and some cross-platform stuff.
Clean up const-correctness of char* pointers.