Fixed a lot of silly bugs in the Arduino code