Bug fixes for partition key handling