stuff for query serialisation, saving, etc