Characterization and Optimization of the KATRIN Tritium Source