Fixed some bugs while checking inheritance