Optimized opening and closing gates.