Added support to use dicts / generate constant ones if a single value is given.
The actual cost is now calculated on each iteration rather than at the end.