Improve exception handling and fix initializer templates.