Fix a alot of query issues