Several fixes.
Remove debug code.