Fix adjust a byte count to the expected int len, and some trivial helpers.