Fixed some bugs, updated the docs