General code restyling, DEBUG_MODE and TEST_KINCHAIN defines added.