Added sort options to search. Some extra error handling.