Commenting

Some commenting done to make code easier to read
Refactoring to OOP

Wrapped procedural code into a function and made it a class method.