Switch from MySQL to SQLite
fix bugs in the previous commit