Tidying up the app core code, to make SQLITE3 querying easier
WIP getting upload history data to behave nicely on updates as well as inserts
Fixing the integrity error import