Refactoring and new generatecfg plugin