Fix some debugging-related bugs