Move HAVING execution to "do" part.
Fixing bugs.