Fixing render scripts

@julian1 this seems to fix the file rendering issues I was seeing. You can have a bit of a think and see if you're happy with this.