refactoring and reorganization of yaml parsing