Improve docs and sinplify code