Clean up code some more, using a more OO approach