Fix 2 resource leaks and fix another pipe-to-comma conversion