Misc fixes to dupe checks and formatting