fixed diagnostics
several functions moved outside np>0 conditional statement