better handing of -internal and some additional debugging