Inserting a few debugging statemenets and cleaning up output