Fix compilation and clean-up code.

Note: Rotating a 2D viewer is not working in connection with the xy2ijk function and won't be fixed because rotating soon will be deprecated.