Nice big refactoring moving from procedural to object-oriented