Raise embedded if into parent if.
diff --git a/src/main/java/org/apache/commons/ognl/ASTChain.java b/src/main/java/org/apache/commons/ognl/ASTChain.java
index 23026f9..8ca6e3c 100644
--- a/src/main/java/org/apache/commons/ognl/ASTChain.java
+++ b/src/main/java/org/apache/commons/ognl/ASTChain.java
@@ -75,71 +75,68 @@
         {
             boolean handled = false;
 
-            if ( i < ilast )
+            if ( (i < ilast) && (children[i] instanceof ASTProperty) )
             {
-                if ( children[i] instanceof ASTProperty )
+                ASTProperty propertyNode = (ASTProperty) children[i];
+                int indexType = propertyNode.getIndexedPropertyType( context, result );
+
+                if ( ( indexType != OgnlRuntime.INDEXED_PROPERTY_NONE )
+                    && ( children[i + 1] instanceof ASTProperty ) )
                 {
-                    ASTProperty propertyNode = (ASTProperty) children[i];
-                    int indexType = propertyNode.getIndexedPropertyType( context, result );
+                    ASTProperty indexNode = (ASTProperty) children[i + 1];
 
-                    if ( ( indexType != OgnlRuntime.INDEXED_PROPERTY_NONE )
-                        && ( children[i + 1] instanceof ASTProperty ) )
+                    if ( indexNode.isIndexedAccess() )
                     {
-                        ASTProperty indexNode = (ASTProperty) children[i + 1];
+                        Object index = indexNode.getProperty( context, result );
 
-                        if ( indexNode.isIndexedAccess() )
+                        if ( index instanceof DynamicSubscript )
                         {
-                            Object index = indexNode.getProperty( context, result );
-
-                            if ( index instanceof DynamicSubscript )
+                            if ( indexType == OgnlRuntime.INDEXED_PROPERTY_INT )
                             {
-                                if ( indexType == OgnlRuntime.INDEXED_PROPERTY_INT )
-                                {
-                                    Object array = propertyNode.getValue( context, result );
-                                    int len = Array.getLength( array );
+                                Object array = propertyNode.getValue( context, result );
+                                int len = Array.getLength( array );
 
-                                    switch ( ( (DynamicSubscript) index ).getFlag() )
-                                    {
-                                        case DynamicSubscript.ALL:
-                                            result = Array.newInstance( array.getClass().getComponentType(), len );
-                                            System.arraycopy( array, 0, result, 0, len );
-                                            handled = true;
-                                            i++;
-                                            break;
-                                        case DynamicSubscript.FIRST:
-                                            index = ( len > 0 ) ? 0 : -1;
-                                            break;
-                                        case DynamicSubscript.MID:
-                                            index = ( len > 0 ) ? ( len / 2 ) : -1;
-                                            break;
-                                        case DynamicSubscript.LAST:
-                                            index = ( len > 0 ) ? ( len - 1 ) : -1;
-                                            break;
-                                        default:
-                                            break;
-                                    }
-                                }
-                                else
+                                switch ( ( (DynamicSubscript) index ).getFlag() )
                                 {
-                                    if ( indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT )
-                                    {
-                                        throw new OgnlException( "DynamicSubscript '" + indexNode
-                                            + "' not allowed for object indexed property '" + propertyNode + "'" );
-                                    }
+                                    case DynamicSubscript.ALL:
+                                        result = Array.newInstance( array.getClass().getComponentType(), len );
+                                        System.arraycopy( array, 0, result, 0, len );
+                                        handled = true;
+                                        i++;
+                                        break;
+                                    case DynamicSubscript.FIRST:
+                                        index = ( len > 0 ) ? 0 : -1;
+                                        break;
+                                    case DynamicSubscript.MID:
+                                        index = ( len > 0 ) ? ( len / 2 ) : -1;
+                                        break;
+                                    case DynamicSubscript.LAST:
+                                        index = ( len > 0 ) ? ( len - 1 ) : -1;
+                                        break;
+                                    default:
+                                        break;
                                 }
                             }
-                            if ( !handled )
+                            else
                             {
-                                result =
-                                    OgnlRuntime.getIndexedProperty(
-                                        context,
-                                        result,
-                                        propertyNode.getProperty( context, result ).toString(),
-                                        index );
-                                handled = true;
-                                i++;
+                                if ( indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT )
+                                {
+                                    throw new OgnlException( "DynamicSubscript '" + indexNode
+                                        + "' not allowed for object indexed property '" + propertyNode + "'" );
+                                }
                             }
                         }
+                        if ( !handled )
+                        {
+                            result =
+                                OgnlRuntime.getIndexedProperty(
+                                    context,
+                                    result,
+                                    propertyNode.getProperty( context, result ).toString(),
+                                    index );
+                            handled = true;
+                            i++;
+                        }
                     }
                 }
             }
@@ -158,77 +155,74 @@
 
         for ( int i = 0, ilast = children.length - 2; i <= ilast; ++i )
         {
-            if ( i <= ilast )
+            if ( (i <= ilast) && (children[i] instanceof ASTProperty) )
             {
-                if ( children[i] instanceof ASTProperty )
+                ASTProperty propertyNode = (ASTProperty) children[i];
+                int indexType = propertyNode.getIndexedPropertyType( context, target );
+
+                if ( ( indexType != OgnlRuntime.INDEXED_PROPERTY_NONE )
+                    && ( children[i + 1] instanceof ASTProperty ) )
                 {
-                    ASTProperty propertyNode = (ASTProperty) children[i];
-                    int indexType = propertyNode.getIndexedPropertyType( context, target );
+                    ASTProperty indexNode = (ASTProperty) children[i + 1];
 
-                    if ( ( indexType != OgnlRuntime.INDEXED_PROPERTY_NONE )
-                        && ( children[i + 1] instanceof ASTProperty ) )
+                    if ( indexNode.isIndexedAccess() )
                     {
-                        ASTProperty indexNode = (ASTProperty) children[i + 1];
+                        Object index = indexNode.getProperty( context, target );
 
-                        if ( indexNode.isIndexedAccess() )
+                        if ( index instanceof DynamicSubscript )
                         {
-                            Object index = indexNode.getProperty( context, target );
-
-                            if ( index instanceof DynamicSubscript )
+                            if ( indexType == OgnlRuntime.INDEXED_PROPERTY_INT )
                             {
-                                if ( indexType == OgnlRuntime.INDEXED_PROPERTY_INT )
-                                {
-                                    Object array = propertyNode.getValue( context, target );
-                                    int len = Array.getLength( array );
+                                Object array = propertyNode.getValue( context, target );
+                                int len = Array.getLength( array );
 
-                                    switch ( ( (DynamicSubscript) index ).getFlag() )
-                                    {
-                                        case DynamicSubscript.ALL:
-                                            System.arraycopy( target, 0, value, 0, len );
-                                            handled = true;
-                                            i++;
-                                            break;
-                                        case DynamicSubscript.FIRST:
-                                            index = ( len > 0 ) ? 0 : -1;
-                                            break;
-                                        case DynamicSubscript.MID:
-                                            index = ( len > 0 ) ? ( len / 2 ) : -1;
-                                            break;
-                                        case DynamicSubscript.LAST:
-                                            index = ( len > 0 ) ? ( len - 1 ) : -1;
-                                            break;
-                                        default:
-                                            break;
-                                    }
-                                }
-                                else
+                                switch ( ( (DynamicSubscript) index ).getFlag() )
                                 {
-                                    if ( indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT )
-                                    {
-                                        throw new OgnlException( "DynamicSubscript '" + indexNode
-                                            + "' not allowed for object indexed property '" + propertyNode + "'" );
-                                    }
+                                    case DynamicSubscript.ALL:
+                                        System.arraycopy( target, 0, value, 0, len );
+                                        handled = true;
+                                        i++;
+                                        break;
+                                    case DynamicSubscript.FIRST:
+                                        index = ( len > 0 ) ? 0 : -1;
+                                        break;
+                                    case DynamicSubscript.MID:
+                                        index = ( len > 0 ) ? ( len / 2 ) : -1;
+                                        break;
+                                    case DynamicSubscript.LAST:
+                                        index = ( len > 0 ) ? ( len - 1 ) : -1;
+                                        break;
+                                    default:
+                                        break;
                                 }
                             }
-                            if ( !handled && i == ilast )
+                            else
                             {
-                                OgnlRuntime.setIndexedProperty( context, target,
-                                                                propertyNode.getProperty( context, target ).toString(),
-                                                                index, value );
-                                handled = true;
-                                i++;
+                                if ( indexType == OgnlRuntime.INDEXED_PROPERTY_OBJECT )
+                                {
+                                    throw new OgnlException( "DynamicSubscript '" + indexNode
+                                        + "' not allowed for object indexed property '" + propertyNode + "'" );
+                                }
                             }
-                            else if ( !handled )
-                            {
-                                target =
-                                    OgnlRuntime.getIndexedProperty(
-                                        context,
-                                        target,
-                                        propertyNode.getProperty( context, target ).toString(),
-                                        index );
-                                i++;
-                                continue;
-                            }
+                        }
+                        if ( !handled && i == ilast )
+                        {
+                            OgnlRuntime.setIndexedProperty( context, target,
+                                                            propertyNode.getProperty( context, target ).toString(),
+                                                            index, value );
+                            handled = true;
+                            i++;
+                        }
+                        else if ( !handled )
+                        {
+                            target =
+                                OgnlRuntime.getIndexedProperty(
+                                    context,
+                                    target,
+                                    propertyNode.getProperty( context, target ).toString(),
+                                    index );
+                            i++;
+                            continue;
                         }
                     }
                 }
diff --git a/src/main/java/org/apache/commons/ognl/OgnlRuntime.java b/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
index 53fac20..0554887 100644
--- a/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
+++ b/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
@@ -1065,12 +1065,9 @@
             method = getReadMethod( targetClass, propertyName, 0 );
         }
 
-        if ( checkAccessAndExistence )
+        if ( checkAccessAndExistence && (( method == null ) || !context.getMemberAccess().isAccessible( context, target, method, propertyName )) )
         {
-            if ( ( method == null ) || !context.getMemberAccess().isAccessible( context, target, method, propertyName ) )
-            {
-                methodValue = NotFound;
-            }
+            methodValue = NotFound;
         }
         if ( methodValue == null )
         {
@@ -1106,12 +1103,9 @@
         boolean result = true;
         Method method = getSetMethod( context, ( target == null ) ? null : target.getClass(), propertyName );
 
-        if ( checkAccessAndExistence )
+        if ( checkAccessAndExistence && (( method == null ) || !context.getMemberAccess().isAccessible( context, target, method, propertyName )) )
         {
-            if ( ( method == null ) || !context.getMemberAccess().isAccessible( context, target, method, propertyName ) )
-            {
-                result = false;
-            }
+            result = false;
         }
 
         if ( result )
@@ -1195,12 +1189,9 @@
         Class<?> targetClass = target == null ? null : target.getClass();
         Field field = getField( targetClass, propertyName );
 
-        if ( checkAccessAndExistence )
+        if ( checkAccessAndExistence && (( field == null ) || !context.getMemberAccess().isAccessible( context, target, field, propertyName )) )
         {
-            if ( ( field == null ) || !context.getMemberAccess().isAccessible( context, target, field, propertyName ) )
-            {
-                result = NotFound;
-            }
+            result = NotFound;
         }
         if ( result == null )
         {
@@ -1908,14 +1899,10 @@
                     if ( numParms > 0 && methodDescriptor.getMethod().getParameterTypes().length == numParms )
                     {
                         return methodDescriptor.getMethod();
-                    }
-                    else if ( numParms < 0 )
+                    } else if ( (numParms < 0) && (method == null || ( method.getParameterTypes().length
+                        > methodDescriptor.getMethod().getParameterTypes().length )) )
                     {
-                        if ( method == null || ( method.getParameterTypes().length
-                            > methodDescriptor.getMethod().getParameterTypes().length ) )
-                        {
-                            method = methodDescriptor.getMethod();
-                        }
+                        method = methodDescriptor.getMethod();
                     }
                 }
             }