Make current maxDepth atomic