Sorted all search results. Some refactoring.