add debug messages and fix some warnings