Grid mask optimizations