Fix bug related to key depth level detection