Updating SQL and fixed other references to _mailer function