Fixed bug that caused wrong code generation when fetching variables from
base classes