Palette output was inverted.

Also fix dependent logic.