Fix memory leak and other problems parsing settings file.

First, there was a memory leak pointed out by Chris Pinkham.  It was
caused by overwriting the token variable before freeing the newly
malloc'd character array returned from trimwhitespace.

For readability, when fixing this I introduced two new variables to be
used as key/value parsings that will hold the trimmed token that was
malloc'd by trimwhitespace and needs to be freed by the caller.

I also fixed another case where we found all whitespace in a string to
return an empty string from trimwhitespace instead of NULL.

Lastly, added better parsing/logging based on the value returned from
trimwhitespace and cleanup the key/value variables at the end of our
main settings file parsing loop.