Fix #340 and improve stack trace rendering