This is tiny, and possibly unnecessary, but these two generateRandomBits methods could be combined, since they don't seem vastly different.