Account for pending requests; make script more configurable.