debug code + some fixes
fix debug code