Took me a while to figure out as the bug would only happen on specific occasions but it should always work now.
I also updated a couple other things like making tetriminos consist of only two colors at most and having every 6th gap be filled with a color-less block instead of a white one.