tidying fns into relevant filenames. Still not using classes no need

Though i could move the metadata file and key store file into their own
classes, and have those classes know how to serialise/deserialize their
data.