Added documentation, plus cosmetic changes.