Added permissions checks.
Modified the main section to be driven by the yaml file.
Fixed an error message.