An unrefinable chain of a finite group G is a chain of subgroups G = G0 >G1 > · · · > Gt = 1, where each Gi is a maximal subgroup of Gi−1. The length (respectively, depth) of G is the maximal (respectively, minimal) length of such a chain. We studied the depth of finite simple groups in a previous paper, which included a classification of the simple groups of depth 3. Here we go much further by determining the finite groups of depth 3 and 4. We also obtain several new results on the lengths of finite groups. For example, we classify the simple groups of length at most 9, which extends earlier work of Janko and Harada from the 1960s, and we use this to describe the structure of arbitrary finite groups of small length. We also present a number-theoretic result of Heath-Brown, which implies that there are infinitely many non-abelian simple groups of length at most 9. Finally we study the chain difference of G (namely the length minus the depth). We obtain results on groups with chain difference 1 and 2, including a complete classification of the simple groups with chain difference 2, extending earlier work of Brewster et al. We also derive a best possible lower bound on the chain ratio (the length divided by the depth) of simple groups, which yields an explicit linear bound on the length of G/R(G) in terms of the chain difference of G, where R(G) is the soluble radical of G.