Add support for querying messages