Some fixes for external template support

In this PR, you'll find changes for an incremental fix for Issue 1237 that I opened earlier on. There is some more work needed for the chmod support, but the changes here should improve the situation so it may be applied to the main code base.

I added a FIXME in the code to highlight an existing problem.