The major upgrade of the MAGIC telescopes, Part I: The hardware improvements and the commissioning of the system