fixed serval bugs in the logic that calculated how many tools to request.