Improved debug, sometimes hanging, can't understand why