fixed some (possible?) python reference counting bugs.