Properly resolve extend references, fixes #103