cleaned code, added log for number of messages in batch.