Do not iterate over the def element
Activate when pressing Enter or Return
Fix the refcount