Fix frame length calculation