documentation and some bugs