Nonlocal Properties of Two-Qubit Gates and Mixed States, and the Optimization of Quantum Computations