Adding malloc() failure check
Improving formatting for ptn_error