Add builder to BatchGraph and refactor a bit.