Stop using released object's member variable
Add `class` keyword for `friend` declaration