Huge refactoring. Templates are generated again after module split. refs #399, #400
Refactored/fixed last remaining exceptions. refs #406