Found the issue for deleting email. In email.php change
$sql='SELECT count(dept_id) FROM '.DEPT_TABLE.' dept '
.' WHERE email_id IN ('.implode(',', db_input($_POST)).') '
.' OR autoresp_email_id IN ('.implode(',', db_input($_POST)).')';
with:
$sql='SELECT count(dept_id) FROM '.DEPT_TABLE.' dept '.
'WHERE email_id IN ('.
implode(',', db_input($_POST)).
') OR autoresp_email_id IN ('.
implode(',', db_input($_POST)).')';
I'll hunt down the other issue here momentarily...