Moved the writing of the pact file into the complete callback.
DRYed up request code to make it easier to overrwrite.