Made minor changes:
     - Set error message template directory.
     - Moved some code to separate files.