Batch system rewriting and bug fixes