Fix compiler warnings ("undeclared casts", depreceated GC calls); use mem* functions instead of while loops for improved performance

Given the `mem*` calls, this code:

```haxe
class Debug
{
    public static function main():Void
    {
        for (i in 0...10) {
            var arr = [  { age: 18 } ];
            for (i in 0...500000) {
                arr.push({ age: i });
                arr[i].age = i + 10;
            }
            for (i in 0...500000) {
                arr.slice(i, 1);
            }
        }
    }
}
```

went from 9500 to 8500 (measured with `time` command).

Of course this code somehow forces that, but it is definitely faster anyway.