Merged from Develop. Fixed query serialization bug in scripting.