add support for search_type parameter

and some small code cleanups