fix two bugs with maximum packet size calculation