Modified query() to chunk-up large queries and pass them to the user as a generator.
Added logout method.
Changed exception handling slightly within the query-chunking method.