I'll leave the closure in this commit, but dedent everything for ease of reviewing, and add another commit in this PR (that I'll squash before merging) to fix the indentation.