Remove debug statements.
Add input checks and debug output.