Restructured database queries for arbitrary parameters. Upgraded search.