CRM-12814, fixed the total issue, code cleanup and notice fixes

----------------------------------------
* CRM-12814: mailings tab slow performance
  http://issues.civicrm.org/jira/browse/CRM-12814