Fixed a ton of screwups, and tested the code in the raspberry pi