Tidied things up a bit more, added a bunch of documentation