Added validators for package and package group rules

Also contains some refactored code and fixes for publish.