Added batch processing support, metric collection.

Still a bit buggy.