Now deals with inheritance correctly