Improved batching
Fix crashing bug