Rewrote some region-query functions to be more idiomatic, no functional changes.