bunch of refactoring, almost-working autocomplete box