Rule and query creation clean up