Cleanup ERB templates. Add some validations for environment model