Fix most resource warnings under 3.2 and 3.3.

This fixes most, but not all, of the ResourceWarnings under 3.2 and 3.3.