fixed a query bug and implemented publish and revoke (Closes #18)