Bcvars

The pull request merges @aalexandrov 's pull request #460 with the current master and adds support for iterations. Also includes a variety of cleanups.

Missing is the support for branching plans. I would suggest to merge this part now, such that newer patches can build on it.

Since the K-Means example is affected by this change, we need to add an additional variant that assigns the  center id to teh data point, to support the clustering tutorial.