Latest work

It is still pretty ugly, but at least with an integration test it seems to be doing its part.