Fixed id casting on queries.