more diagnostic code and fixes