Fix refcounts and add error checks.
1 file changed