Leftover from d34ae3f0. This code generally needs a refactor to be more declarative, which will be done later.