Cleaned up code by making it object-oriented.

This code will not work on MinGW because of problems with std::random_device. Other than that, this code uses C++11 and the STL.