Add documentation, fix a few small problems.