Just had a Google and the 140 code is caused by faulty thermostat or more specifically its electric control which fools the thermostat to lower engine temperature on high load. This doesn't cause any symptoms in regular driving and doesn't explain your rough running. If you want to get rid of that code you'll need a new thermostat. The 33 code is either one of the Camshaft Position Sensors or something to do with the Vanos (No idea what this is).