SQL queries were reworked according to new database scheme.