Refactoring shard creation code.