Added ability for custom error element templates.

General bugfixes and stability increases.