Rename length to packedLength and other minor cleanup.