Massive clean-up of the code