Optimization of the spill quality for the hadron therapy at the Heidelberg Ion-Beam Therapy Centre