Improved partitioning hash

See #815. Thanks @StephanEwen for the comments!