Various refactors
Revert "Various refactors"

This reverts commit 85173a8a717c52ccbb52c8ea3e3d463003b521ac.