Refactored saving of the big query
Merged with master