Added debug mode. Improved battle handling.