cache layer contruct from config

... and some small indentation fix