fix merging problems and missing null check for inheritedBy