Fixed refcounts and error handling.

Should not be merged to py3k branch.
1 file changed