Regarding your physics, I don't see you setting the friction at all with phent_setfriction(). This is very important for a stack.
Regarding your stack, how close are you stacking? I've found great success at stacking boxes by having them be a few quants off of each other and let them fall into position. If I try to stack boxes by having the faces touch or leaving just 1 quant of space, I get these issues. I also find that a higher than normal gravity helps too...try around -700.
Regarding the color change, I've never seen anything like that in all my time with the PE. Don't know what's going on there.