A strange mix of OO, recursion and procedural code (a work-in-progress)