Add more debug code, change/fix the "-wait" option handling