add debug flag
fix a few exceptions from last change