Added more debug output to third pass
Some other updates