Misc cleanups/improvements
Split off from !668 (merged) to ease reviewing.
Changes are some fixed memory leaks here and there and misc fixes like
- avoiding raising criticals on application shutdown
Split off from !668 (merged) to ease reviewing.
Changes are some fixed memory leaks here and there and misc fixes like