Fixed a bug that caused a crash at the end of a battle. (pointer was dangling)
Cleaned up code.