AIS optimizations

Refactor AIS rendering code and eliminate redundant math calls.