Fixes 1692348. todo: revisit the 'if(z>0 && z<horizon*2)' checks. Is there a better...