added messages query. Implemented chunked messages query (get message before the nth last message, get N message)