Debug prints and possible bug fix