Replaced sprintf with c_snprintf where appropriate