Merge instead of overwrite query with lookup. Addresses #357.