This patch continues the work started with ea5b1ef0. See that commit and its corresponding PR for details.