Cleaned up some areas of the autocompletion code