Allow fiddling of units on import!
repo corruption fixes
attempt write to a tempfile instead of real repo file then rename; actually make a new repo useable if the old one is borked. Zomg and stuff.