New implementation

The previous version has been updated to use classes to help better
organize the code.