added documentation and fixes