refactoring, tagging, versioning, validation and support for json input

Tested on production servers.