Bug fixes and batch mode