Query working except for relations
Small improvements