Worked on executing CMake on the right path
Added some error detection
Fixed multithreading-related bug