improved email model and template system