fixed bugs and improved documentation