Rewrite autocomplete

This implementation contains different logic but uses a series of channel transformations instead of a large function with channel logic mixed with autocomplete logic.

I am sending this pull request because I don't know of a better way to send you a diff. No need to accept.