Replace dodgy use of const char* and memcpy with std::string.

This was backported from commit e01df63 in master.
Kill some logically dead code detected by Coverity.

- m_watch: wl has already been confirmed to not be NULL on L161.
Merge pull request #934 from SaberUK/insp20+fix-various-issues

Fix various issues detected by Coverity.