Fixing locking in incref/decref handling