Added ability to specify indexes and error templates.