Bugfix to allow proper queries on sub-classes