some fixes
added some debug and set some variables