Improve battle factory script

- Fix generation problems
- Remove some obsolete code as well