added documentation; bug fixes