Minor code style update and grid flip.