Updated retrieval of filtered messages with limit and offset parameters.