Bug fixes for batch training