Palette handling fixes

Fixes #513, #434. 

* should probably check transparency interactions as well.