SQLite database + bug fixes