Begone magic numbers! Change 4000 reference to MAX_LAYER_RECURSION_DEPTH.