Imported save contact code from yesterday, plus some refactoring / adaptations.