Crash fixes for text-input
Bunch of fixes for dangling signal listeners and NULL dereferences.
Fixes #116 (closed) and potentially some other reported crashes as well (but given that we had no reliable reproducers for those we'll have to wait and see)