Provisional solved the problem with  unicode strings substitutions in templates
Refactor: write layout fuctionality in its own script