Added debug mode and some logs