Optimization of the electrostatic and magnetic field configuration in the MITICA accelerator