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

Fix for #357.