Np error patch

These two commits should close #3186.

@ianthomas23 Can you review this?