Add some debug and some fixes