Get rid of code duplication for computing length and sending parts