Copied queries

From a discussion months ago - copying queries within functions so the original object isn't modified. issue #4.