fix email address detection and memory bug