Added debug code & cleanup