DRY'ed up the functions and reorganised the YAML file to be more concise.