Seperate Tasks module?
Tasks and Events, Calendar module is a bit of mess as everyone knows. A good starting point would be to create a new Tasks module, unlink emails with vtiger_activities and retain existing Calendar module to be used as Events. Followed by cleanup of all the if/else conditions.