Revert "Remove more unused code"

This reverts commit 725294f37d8f60a01239ad6b0799ac38f3d69f9b.