Fix references to undefined variable and change them to the class accessors.