Fix some quadratic behavior in the AOT compiler.