Add ABC calculation infrastructure
Some bugs fixed