added documentation and a couple of minor fixes