Changed database to sqlite3 and in the process corrected some design flaws from old mysql version.