Made the functions for Typeahead more reusable.