Fixed potential segfaults on autocomplete