Properly handle reference counting with lists/dicts

Inserting into a list or dict increments the refcount of the object
being inserted, so objects created only for insertion need to be
DECREFed after being inserted.

Additionally DECREF objects on error in places where it was missing.

DECREFing a dictionary will also DECREF all of its contents, so don't
DECREF it until done using elements in it.