CNC machining optimization