Rewritten chunk selection code for pull. TODO: test it
Fixed sets initializations