fix broken battles.

major refactoring into more files.