Implement the MBucket algorithms.
Finally find out something wrong with it though.

Change-Id: I62b7ec0bf2d752036aadcb775cf18790fac928a6