add debug mode. fix final stuff