added createQuery for interfacing with query events, fixed a possible leaking resources in query