deduplicate database reading / cleaning
deduplicate repo writing and signing
refactor variable names