adapt to new BuildService api for expandPatterns

also simplify the processing