refactor and comment cleanup
fix setMaxDepth