Store enums in smaller integer types when possible.

This patch is to use small types (e.g. unsigned char) to represent enum instead of int. This has also the property of better specifying the type in structure of the enum (unsigned char is always 8 bits, unsigned short is 16).

Overall it would be better if all integer/type sizes would be explicitely specified in the header files. Since I don't use C++ it would be convenient for me to have fixed structure sizes.