Some refactoring
Revert "Some refactoring"

This reverts commit 212042f8c8621e143c50e3383767647c85a09896.
Revert "Revert "Some refactoring""

This reverts commit 2bdcdbfcfb4d6462206c030962e63f07026c0e9a.