Clean things up a bit. Add a little documentation.