Fixed email error and added try/finally statements.