Added a lot of diagnostics