Beginning of create_pin refactoring.