finished locking implementation in queries. YAY\!