add a library method to clean stack traces

Move a method to sanitize stack traces into the top level of the library.