Reverted back to OO implementation

I jumped back to an object-oriented implementation to make the code
clearer and still efficient.