Get search working; fix some bugs