Adds documentation and check corner cases, close #11 #9 #8 #7 #6