fixed bugs and improved docs