updated max depth and bug fixes