address Madhusudan's review comments
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java
index 59c9ed0..6cb4d5c 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java
@@ -449,19 +449,17 @@
                     }
                     if (argExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
                         //recursively rewrite function arguments
-                        if (!castInjected
-                                && TypeComputerUtilities.getRequiredType((AbstractFunctionCallExpression) argExpr) == null
+                        if (TypeComputerUtilities.getRequiredType((AbstractFunctionCallExpression) argExpr) == null
                                 && reqFieldType != null) {
-                            //rewrite arg
-                            ScalarFunctionCallExpression argFunc = (ScalarFunctionCallExpression) argExpr;
-                            rewriteFuncExpr(argFunc, reqFieldType, inputFieldTypes[i], env);
-                        }
-                        if (castInjected
-                                && TypeComputerUtilities.getRequiredType((AbstractFunctionCallExpression) argExpr) == null
-                                && reqFieldType != null) {
-                            //rewrite the arg expression inside the dynamic cast
-                            ScalarFunctionCallExpression argFunc = (ScalarFunctionCallExpression) argExpr;
-                            rewriteFuncExpr(argFunc, inputFieldTypes[i], inputFieldTypes[i], env);
+                            if (castInjected) {
+                                //rewrite the arg expression inside the dynamic cast
+                                ScalarFunctionCallExpression argFunc = (ScalarFunctionCallExpression) argExpr;
+                                rewriteFuncExpr(argFunc, inputFieldTypes[i], inputFieldTypes[i], env);
+                            } else {
+                                //rewrite arg
+                                ScalarFunctionCallExpression argFunc = (ScalarFunctionCallExpression) argExpr;
+                                rewriteFuncExpr(argFunc, reqFieldType, inputFieldTypes[i], env);
+                            }
                         }
                     }
                 }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
index 415ee33..f29d6be 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
@@ -80,7 +80,6 @@
                 @Override
                 public void init(IFrameTupleReference tuple) throws AlgebricksException {
                     try {
-                        metNull = false;
                         inputVal.reset();
                         argEval.evaluate(tuple);
                         ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER