Lowering the scope And cleaning up some warnings from static analysis