Add support for environments, CmsInput protection, better logging