Implemented depth limit
bug fixes