Added diagnostics, and changed scopes