Updated SQL queries for new schema
Added SQLite error messages
Fixed log messages