I2C seems to stop working when I attach an AF motor shield
Motors draw large amounts of current, and will either cause your power supply voltage to sag if you draw more current than your power supply can support, or cause blips in the power supply that will cause you all sorts of problems. 

You need to take steps to isolate the power from the motor shield from the power for the Arduino. 

How are you powering the motor shield? How are you powering the Arduino?

If your power supply has enough current to support both your Arduino and your motors then you can probably solve the problem by adding an isolation capacitor between the Vin port on your Arduino and ground. 

What that does is to filter out temporary variations in the input voltage that's being fed to the Arduino. Without it, the Vin voltage to the Arduino is probably dropping as your motor draws large pulses of current, and that causes the output from the voltage regulator to droop as well.

I don't know how to pick the rating of the cap. A trip to the Electrical Engineering stack exchange is probably in order.