return early on error, stop using isNull() when it is an empty block - better than #513

Fixes all sorts of problems with issue #513 while still reducing code over original docs.