Latest work

It is still pretty ugly, but at least with an integration test it seems to be doing its part.
Just putting enough code together so that it works.