Initially the NullDerefProtectionTransformer was prepending a If statement before the possible Null derefrencing. This was chenged by a runtime function call which included the check for Null and invalid address memory, but was replacing the whole AST node so the parent node of the Expr type would disappear, resulting in a wrong AST. The correct solution was to replace the SubExpr of the Expr that contained a possible Null derefrencing. This was done by using the specific setters for each Expr type that is detailed in the NullDeref Visiting.