Fix use-after-free bug with cached settings values

This patch fixes a couple of use-after-free bugs when caching various
string related setting values.

Fixes: #143
I see an issue...