Updated queries, bug fixes