Fixes to legen query for client version 2