Added almost all the bluetooth code in.