added some debug code & fixed compiler warning