Clean up and add some more documentation