Config parsing refactoring, minor bugfixes