adjusted some queries to new db structure
small mods