I think the stacking bug is caused by items that have different graphics despite being otherwise identical.
I don't think this is the case. I have three stacks of regular healing potions in my inventory, all with the same graphic and descriptions, that don't stack. The only difference is that one stack is stolen.