Resolving inner definitions on $ref's