Revert "tidy"

This reverts commit dd3d4df4b41101991756e68f9542fe6bcec51355.
Revert "Revert "rewrite""

This reverts commit d63016c78854ad90d1924ee09ba6aee322e6472a.