Two small changes:

1. Fixed bug where boolean "and" was incorrectly used instead of bitwise "&".  We're testing a bit in a byte.
2. Moved the sleep call to BEFORE the first read.  Occasional errors with immediate read after write.

Regarding the issue of moving the sleep command, I can't be sure this isn't a solution to a software bug or an issue with the device.  I did find evidence of people having similar trouble and one instance where someone theorized that the "write" operation sucked too much power, causing the following read operation to fail, but that might be silliness.  All I can say for certain is that this appears to make the problem go away.