Moving some debug code around