A lot of improvements. Now the script is more or less working. Also submitting result to PgSQL DB.