More db work and use templates for content.

Introduced global environment, which is used as configuration and with templates.