Better C++ Practices

Checked the algorithm and abstracted it into a class. Much cleaner code
and we generate text files for analysis by excel.