Move client and query code to Internal/Client.chs