Updated version of the program, with cmake file (suitable for Mac).