Major overhaul of the whole attribute / sgr code tracking internals

Also added:
  * screen.optimize, to compress redundant color codes
  * VGA palette