Added support for templates and other wiki text in file argument
Did some minor refactoring