added documentation and some other bug fixes