Fixes two issues found during stabilizer run

I will backport this to 3.2.6 and 3.3 soon.