Switched build system to use CMake. And fixed lots of warnings.