file reorganization and added sqlite3_open & sqlite3_close to speed things up