formatting and reorder of processing for caching kms data

KMS data now pulled AFTER item id check and item insert to link
a dossier to an item. Updated ambiguous variable name!