Rewrite autocomplete and add some comment to describe it.