diagnostics added and some cleanup