added batching and postgres support