Fixed available and wanted media query
Fix for queries being executed before tables created