Fix some issues spotted by David Faure.
In particular, add a check for partition capacity to be positive.