Fix a bug and improve project cloning code