Fixed issue with incorrect depth calculations.