More debug prints and fixed a bug