Finish models, add resale blueprint, add generate_key helper, minor tidying