ranks added, code improved, diff added via "Diff Match and Patch" from Google under Apache License