BIG REFACTOR. The code is now modular, based on a system of states.
Revert "BIG REFACTOR. The code is now modular, based on a system of states."

This reverts commit bb2152f5a57928e4d57a8c282318acc018d3e5af.