I managed to fix this using the code and idea in here and here. Basically, I serialized the dataset, converted it to bytestorage, padded it (since my data was not of the same size), gathered and then unpadded and unserialized it.