Refactored bits of PreparedQuery.