fixed bugs, documented a little