Added support for nested query strings in fromQuery and toQuery functions