Fix sending more than one variable

The code neglected to get an ACK packet, which was a problem when
sending more than one variable.  Also, this fixes a few poor programming
practices.