Quantum gates and Berry phases in Josephson nanostructures