Fixes in sdb_query for ';' and references