End of the refactoring. Successfully tested.