API query improvements, fixes