Depth order fixes

The calculation of depth classes and the amount of memory needed to hold
all subpatches of all classes was fixed.