#4 batching and fixed various bugs