Fix the package stats computation

This is related to #793, although not fixing it completely.