changes to templatereader and lay out engine