Added some debug code into the system and am about to refactor into functions