add debug and minor changes