fix bugs and documentation