Fixes for crashes and stacktraces