Move stack trace formatting to separate file