documentation and some improvements