Fix most analysis results discovered in bug 3907

Thanks @rlerdorf!