Fix for #22 

The template name wasn't handled correctly for folders. I also did some minor cleanup of unused code after the refactoring.