More battle code optimizations