Fix formatting and protect for undefined file names