Harden the locking mechanisms

Eliminate a lot of potential deadlocks by adding a try, finally construct around the locks, to ensure that the lock is always given back, even when an error occurs.
Fix memory leak when overwriting callbacks

Puts a check in place, that when there already is a callback, it is properly freed.
Implement onStatusMessage callback
Add callbacks for read_receipts and connection status