Minor refactoring, added some more validations (aliases, types), and fixed whole script exit status according to number of failures