Split up monolithic `constructChain` function
Split up monolithic `constructChain` function

The behaviour of `constructChain` is not changed. Smaller helper
functions are added to improve readablity.

clample/lamdabtc,clample/lambdabtc,clample/lamdabtc,clample/lambdabtc