Revert "Merge pull request #2950 from dimagi/refactor"

This reverts commit 6038175e6b91718226f2301d26c5377d58e9c773, reversing
changes made to a7415ca5c8f39e506baba1cc13db1ed8b56934e9.