expand y_batch_mask
a lot of small changes