diagnostics - importing old code, wip