Add memory debug code
Some memory management fixes
x00 scratch