Added piece counts, and manifest writing