[#858] Removed empty else block
[#2212] CID25766:

Null check to avoid null dereference
[#2212] CID25808:

Added null check to prevent null dereference
[#2222] [#2212] CID25693, CID25725:

Refactored addKeyVal to be more straightforward