Fixes to diagnostics functions, etc