This commit fixes several Coverity defects.
Fixes CID 10508 (Resource leak).
Fixes CID 10882 (Uninitialized pointer read).
Fixes CID 10486, 10487, 10488, 10519, 10520, 10521 (Resource leak).
Fixes CID 10509-10513 (Resource leak).
Fixes CID 10177 (Missing return statement).
Remove dead code. Fixes CID 10481, 10482, 10517, 10518 (Resource leak).
Fixes CID 10443, 10444, 10445 (Printf arg type mismatch).
Initalize class data member in constructor. Fixes CID 10907, 10908 (Uninitialized scalar field).
Initalize class data member in constructor. Fixes CID 10920 (Uninitialized scalar field).
Fixes CID 10137 (Unchecked dynamic cast).
Fixes CID 10525 (Dereference before null check).
Fixes CID 10119.
Fixes CID 10123, 10124, 10125.
Fixes CID 10126.
Fixes CID 10126.
Fixes CID 10140.
Fixes CID 10892.