Bug fixes and implementation of UserQuery