Improve batch mechanism

Revision History
1st PR:
. Fix issue #91 
. Fix issue #95

Valgrind tests passed, so do all make-test.