code fixes; added documentation