Fixes for Parfait errors - mostly unhandled NULL pointer dereference and data type mismatch