tidy up code a little
Add in DistributedQuery objcet and json form for query distribution