Gradelize the detect_partitions branch in preparation for merging with master