Add CMakeLists.txt and remove Makefile
Reduce some spaghetti code in main