Some work on supporting 16bpp, cleanup