fix file save, clean up some debug