allow to specify the number of records to extract in read_message()
just some casts to suppress warnings