Fix autosuggestion and make it async

This PR supersedes #620