C Controller V2

Some bugs fixed.
Added extensive debugging file logging.