Refactor setting of actualcode to go through functions so that we can set httpCode at the same time.