Revert "Merge pull request #869 from dimagi/remove-dead-code"

This reverts commit 62bb6640a61ca24d1fe45551cbb7f921eccd417c, reversing
changes made to 671f5cc43153d481b169a5d6fcbb7d9f3a6a51e0.