Make cleanQuery run after middleware

Signed-off-by: Ian Macalinao <me@ian.pw>