Fixed potential null pointer dereferences
Removed some redundant not-null checks
Updated a check in cbtls_msg

The check does exactly the same thing as before, but this silences a cppcheck warning.