Doubt the thermostat would cause this, does it cut out when it's rough ever?
What do you mean by banks 1 and 2 - a 525i is a straight six, banks are usually used for V engines. Unless the Banks are inlet and exhaust cams, in which case I'd be looking at the camshaft position sensor first, then valve timing.