Fixed errors caused by migration to Query objects