Cleaned up.
enum values changed slightly.
typedef comp-related functions debugged and logic simplified. Unused function removed.