* Limited batch replication size to 1000.

* Improved batch message processing.
* Cleaned up code.