Cleaned up map_pixel() a bit.

Probably would be better with a little inline ASM.
Much better get_hex()
Fixed memory leaks in make_gchr()
Fixed another memory leak, fixed some idiomatic errors.