Basic optimizations to ai