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
Merge pull request #147 from ahf/bugfix-143

Fix use-after-free bug with cached settings values