Tidy up by removing some duplicate code; add framework to track payload requests through the file id