harden against random input data.
removed debug output.