update documentation and fix bugs