Complete re-write of mdattack