Whip the query model generating code into decent shape.