Fix some CID issues (v2)

Fixes for:
- possible NULL pointer dereference
- silence CID COPY_PASTE_ERROR warning

---
v2: change MDS.cc fix as proposed in comment to pull request #298