fixed #21: ClassCastException: LazyLinkingResource cannot be cast to DerivedStateAwareResource
fixed a potential index out of bounds exception