Cleaned up autocomplete code