Added detection of corrupted config files. Plus some minor refactoring
Merge pull request #116 from thymikee/config-bug

Fixes #114. Added detection of corrupted config files. Plus some minor refactoring.