Bugfix error checking

Hi icanzilb,

I may be wrong, but it looks to me, that sometimes the wrong errors get checked, e.g. an error which MUST be nil at the point we check. See the attached commits to see what I mean.

Regards,
Christian