added possebility to set debug level
some more debug changes
added some doc