Fix compile warnings and misc. build issues

I haven't tried to build using Eclipse,
but these changes allow clean builds on OS X and CentOS.