Fix some issues discovered via static analysis

9 jobs for static_analys_fixes in 2 minutes and 49 seconds (queued for 1 second)