code cleanup and tons of work on stacktraces