Add global declarations and fix orientation of the coordinate system.