Fixes only

This is the first of multiple pull requests. The only thing this pull request does is fix the fatal errors that occur when a template file is empty. 

Let me know what you think!