This is a working version of these scripts. We need to integrate sqlite3 instead of write log to files.