Io dev

Please test and merge into master.
I will keep building atop this on a new branch.
TODOs:
- Convert database to INSERT OR FAIL (rather than replace)
- Turn FOREIGN KEY CONSTRAINTS on
- Add R plots to script and improve them...