fix for provider selection and cost-based provider selection, fixes: #365

just a fix for the issue #365

no tests; working on them in separate branch