Fix some bounds issues with partitions. Closes #519