Refactor as class to provide more structure for caches

Since the goal is to pipe 100k trees through this project we want to
cache as many values in memory as possible. It seems to make sense to
encapsulate everything into a class with a mutable cache
Add tests

Create an initial batch of tests.