sanity check input and improve npn debugging