Converted to CMake and small fixes