Added global config options and refactoring.