work in progress
Revert "Remove old unused code."

This reverts commit 6a617348e5ba2e376f8d41f5432e5c95940dd66a.