some improvements and fixes for 256 colour.