Prevent a rare security exception

This should fix CID18178, and probably others
Make Configuration thread-safe and clean it
Remove duplicate IsRunningOnLinux/Mac