Changed expansion function to work with all completion frontends.