refactored a lot to support "depth" parameter
simplified traceback output for compatibility with elasticsearch