Added support for searching; cleaned up clien code a little