Debug code fixes