Fix and optimize finding of active pull requests