Corrections for depth (including x,y projection, variables slightly tidied.