Integrate partition, fix some nasty bugs.