Refactor config template processing