First commit. All working, complete rewrite of code to take advantage of c++.