refactoring config loader and adding some SIGPIPE handling because apparently this is nonstandard stuff.