I would definitely walk away from the 335. It will be immediately worth less than what you will have to pay for it because of the accident. That is a very easy decision IMO. While I love the M5, I am not sure that I would want to own one of those either. It is a blast if you are driving it fast everywhere, but there are some serious downsides.
The SMG is very well suited for this car, much more so than the 6mt. That said if you are trying to drive it slowly it will be annoyingly jerky. The v10 is amazing, but I would expect to get half the MPG you are getting with the 335. It is really a compromise of a car. It is amazingly fast and the v10 is truly remarkable but it isn't at all practical other than it can seat 4 people comfortably. Also something to consider is that this car has tanked in value. At 50k it may seem like a great deal right now, but it will continue to tank simply because of the nature of this car (expensive to maintain, terrible fuel economy, marginal styling IMO).
If I were to spend 50k on a car, I would go a different route. You can pick up some great new cars for that much. I don't want to completely discredit the M5, but I would do some serious research before buying one and determine if it is really a car you want to own. For what it's worth I have spent a great deal of time behind the wheel of two different M5's and it is just an absolute beast, but make sure you are well informed of the compromises upfront.