work in progress, some debug changes