CompletionWords: simplify the library code

The new g_sequence_lookup() function simplifies the code.
CompletionWords: simplify the buffer code