bit twiddling mess made better