Refactor traceback formatting