First commit

Needs documentation and a lot of tidying up