Should probably avoid declaring variable in if statement (same for localAddr and remoteAddr below).