Revert "Complete refactor"

This reverts commit 400ea2b884fb033fe67a5162e837814253dc8c3d.