Fixed bugs.
Added debug code.