Fixed some bugs and added couple little features to TextDocument and TextRange classes.