fixed bugs, added docs