neaten up a few things and add some more docs