diff --git a/rollo-old.c b/rollo-old.c
deleted file mode 100644
index 5ed562a..0000000
--- a/rollo-old.c
+++ /dev/null
@@ -1,184 +0,0 @@
-#pragma version(1)
-#pragma stateVertex(PV)
-#pragma stateFragment(PF)
-#pragma stateFragmentStore(PFS)
-
-// Scratch buffer layout
-#define SCRATCH_FADE 0
-#define SCRATCH_ZOOM 1
-#define SCRATCH_ROT 2
-
-//#define STATE_POS_X             0
-#define STATE_DONE              1
-//#define STATE_PRESSURE          2
-#define STATE_ZOOM              3
-//#define STATE_WARP              4
-#define STATE_ORIENTATION       5
-#define STATE_SELECTION         6
-#define STATE_FIRST_VISIBLE     7
-#define STATE_COUNT             8
-#define STATE_TOUCH             9
-
-
-float filter(float val, float target, float str)
-{
-    float delta = (target - val);
-    return val + delta * str;
-}
-
-int main(void* con, int ft, int launchID)
-{
-    int rowCount;
-    int row;
-    int col;
-    int imageID;
-    int done = loadI32(0, STATE_DONE);
-    int selectedID = loadI32(0, STATE_SELECTION);
-
-    float f = loadF(2, 0);
-
-    pfClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-    if (done) {
-        if (f > 0.02f) {
-            //f = f - 0.02f;
-            //storeF(2, 0, f);
-        }
-    } else {
-        if (f < 0.8f) {
-            f = f + 0.02f;
-            storeF(2, 0, f);
-        }
-    }
-
-    float touchCut = 1.f;
-    if (loadI32(0, STATE_TOUCH)) {
-        touchCut = 4.f;
-    }
-
-
-    float targetZoom = ((float)loadI32(0, STATE_ZOOM)) / 1000.f;
-    float zoom = filter(loadF(2, SCRATCH_ZOOM), targetZoom, 0.15 * touchCut);
-    storeF(2, SCRATCH_ZOOM, zoom);
-
-    float targetRot = loadI32(0, STATE_FIRST_VISIBLE) / 180.0f * 3.14f;
-    targetRot = targetRot * 0.80f - .12f;
-    float drawRot = filter(loadF(2, SCRATCH_ROT), targetRot, 0.1f * touchCut);
-    storeF(2, SCRATCH_ROT, drawRot);
-
-    float diam = 8.f;
-    float scale = 1.0f / zoom;
-
-    // Bug makes 1.0f alpha fail.
-    color(1.0f, 1.0f, 1.0f, 0.99f);
-
-    float rot = drawRot * scale;
-    float rotStep = 16.0f / 180.0f * 3.14f * scale;
-    rowCount = 4;
-    int index = 0;
-    int iconCount = loadI32(0, STATE_COUNT);
-    while (iconCount) {
-        float tmpSin = sinf(rot);
-        float tmpCos = cosf(rot);
-            //debugF("rot", rot);
-
-        float tx1 = tmpSin * diam - (tmpCos * scale * 0.9f);
-        float tx2 = tx1 + (tmpCos * scale * 1.8f);
-        float tz1 = tmpCos * diam + (tmpSin * scale * 0.9f);
-        float tz2 = tz1 - (tmpSin * scale * 1.8f);
-
-        int y;
-        for (y = rowCount -1; (y >= 0) && iconCount; y--) {
-            float ty1 = ((y * 3.1f) - 5.f) * scale;
-            float ty2 = ty1 + scale * 1.8f;
-            bindTexture(NAMED_PF, 0, loadI32(1, index));
-            drawQuad(tx1, ty1, tz1,
-                     tx2, ty1, tz2,
-                     tx2, ty2, tz2,
-                     tx1, ty2, tz1);
-
-            iconCount--;
-            index++;
-        }
-        rot = rot + rotStep;
-    }
-
-    if ((zoom < 1.1f) && (zoom > 0.9f)) {
-        bindProgramVertex(NAMED_PVOrtho);
-        bindProgramFragment(NAMED_PFText);
-        bindProgramFragmentStore(NAMED_PFSText);
-
-        rot = drawRot * scale;
-        index = 0;
-        iconCount = loadI32(0, STATE_COUNT);
-        while (iconCount) {
-            int y;
-
-            float tx = 240.f + floorf(sinf(rot) * 430.f) - 64.f + 16.f;
-
-            float alpha = 2.4f - (fabsf(tx - 240.f + 48.f) / 76.f);
-            if (alpha > 0.99f) {
-                alpha = 0.99f;
-            }
-            alpha = alpha * (1.f - (fabsf(zoom - 1.f) * 10.f));
-
-            tx = tx + 0.25f;
-
-            for (y = rowCount -1; (y >= 0) && iconCount; y--) {
-
-                if (alpha > 0) {
-                    color(1.0f, 1.0f, 1.0f, alpha);
-
-                    float ty = 654.f - y * 150.f;
-
-                    ty = ty + 0.25f;
-
-                    bindTexture(NAMED_PFText, 0, loadI32(3, index));
-                    drawRect(tx, ty, tx + 128.f, ty + 64.f, 0.5f);
-                }
-                iconCount--;
-                index++;
-            }
-            rot = rot + rotStep;
-        }
-
-
-        bindProgramVertex(NAMED_PV);
-        bindProgramFragment(NAMED_PF);
-        bindProgramFragmentStore(NAMED_PFS);
-    }
-
-    // Draw the selected icon
-    color(1.0f, 1.0f, 1.0f, 0.9f);
-    rot = drawRot * scale;
-    index = 0;
-    iconCount = loadI32(0, STATE_COUNT);
-    while (iconCount) {
-        int y;
-        for (y = rowCount -1; (y >= 0) && iconCount; y--) {
-            if (index == selectedID) {
-
-                float tmpSin = sinf(rot) * scale;
-                float tmpCos = cosf(rot) * scale;
-                float tx1 = tmpSin * diam * 0.9f - tmpCos * 2.f;
-                float tx2 = tx1 + (tmpCos * 4.f);
-                float tz1 = tmpCos * diam * 0.9f + tmpSin * 2.f;
-                float tz2 = tz1 - (tmpSin * 4.f);
-
-                float ty1 = ((y * 3.1f) - 4.5f) * scale;
-                float ty2 = ty1 + scale * 4.f;
-                bindTexture(NAMED_PF, 0, loadI32(1, index));
-                drawQuad(tx1, ty1, tz1,
-                         tx2, ty1, tz2,
-                         tx2, ty2, tz2,
-                         tx1, ty2, tz1);
-            }
-            iconCount--;
-            index++;
-        }
-        rot = rot + rotStep;
-    }
-
-    return 1;
-}
-
-
diff --git a/src/com/android/launcher2/AllAppsGridView.java b/src/com/android/launcher2/AllAppsGridView.java
deleted file mode 100644
index 71cd952..0000000
--- a/src/com/android/launcher2/AllAppsGridView.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher2;
-
-import android.widget.GridView;
-import android.widget.AdapterView;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.util.AttributeSet;
-import android.view.View;
-import android.graphics.BitmapFactory;
-import android.graphics.Bitmap;
-import android.graphics.Paint;
-import android.graphics.Canvas;
-
-public class AllAppsGridView extends GridView implements AdapterView.OnItemClickListener,
-        AdapterView.OnItemLongClickListener, DragSource {
-
-    private DragController mDragController;
-    private Launcher mLauncher;
-    private boolean mDraw = true;
-
-    public AllAppsGridView(Context context) {
-        super(context);
-    }
-
-    public AllAppsGridView(Context context, AttributeSet attrs) {
-        this(context, attrs, com.android.internal.R.attr.gridViewStyle);
-    }
-
-    public AllAppsGridView(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-    }
-
-    @Override
-    protected void onFinishInflate() {
-        setOnItemClickListener(this);
-        setOnItemLongClickListener(this);
-    }
-
-    public void onItemClick(AdapterView parent, View v, int position, long id) {
-        ApplicationInfo app = (ApplicationInfo) parent.getItemAtPosition(position);
-        mLauncher.startActivitySafely(app.intent);
-    }
-
-    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
-        if (!view.isInTouchMode()) {
-            return false;
-        }
-
-        ApplicationInfo app = (ApplicationInfo) parent.getItemAtPosition(position);
-        app = new ApplicationInfo(app);
-
-        mDragController.startDrag(view, this, app, DragController.DRAG_ACTION_COPY);
-        mLauncher.closeAllApps();
-        mDraw = false;
-        invalidate();
-        return true;
-    }
-
-    @Override
-    protected void dispatchDraw(Canvas canvas) {
-        if (mDraw) {
-            super.dispatchDraw(canvas);
-        }
-    }
-
-    public void setDragController(DragController dragController) {
-        mDragController = dragController;
-    }
-
-    public void onDropCompleted(View target, boolean success) {
-        mLauncher.closeAllApps();
-    }
-
-    void setLauncher(Launcher launcher) {
-        mLauncher = launcher;
-    }
-
-    void onPrepareDialog() {
-        mDraw = true;
-    }
-}
diff --git a/src/com/android/launcher2/AllocationIndex.java b/src/com/android/launcher2/AllocationIndex.java
deleted file mode 100644
index 0202db5..0000000
--- a/src/com/android/launcher2/AllocationIndex.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher2;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Annotate fields of a subclass of {@link IntAllocaiton} or
- * FloatAllocation with this, and the save() method on those
- * those classes will find the field an save it.
- * <p>
- * TODO: This would be even better if the allocations were
- * named, and renderscript automatically added them into to
- * the renderscript namespace.
- */
-@Retention(RetentionPolicy.RUNTIME)
-public @interface AllocationIndex {
-    /**
-     * The index in the allocation to use inside renderscript.
-     */
-    int value();
-}
diff --git a/src/com/android/launcher2/IntAllocation.java b/src/com/android/launcher2/IntAllocation.java
deleted file mode 100644
index dde3d22..0000000
--- a/src/com/android/launcher2/IntAllocation.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher2;
-
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.util.Log;
-
-import java.lang.reflect.Field;
-
-public class IntAllocation {
-    private RenderScript mRS;
-    private int[] mBuffer;
-    private Allocation mAlloc;
-
-    public IntAllocation(RenderScript rs) {
-        mRS = rs;
-    }
-
-    public void save() {
-        Field[] fields = this.getClass().getFields();
-        if (mBuffer == null) {
-            int maxIndex = 0;
-            for (Field f: fields) {
-                AllocationIndex index = f.getAnnotation(AllocationIndex.class);
-                if (index != null) {
-                    int value = index.value();
-                    if (value > maxIndex) {
-                        maxIndex = value;
-                    }
-                }
-            }
-            mBuffer = new int[maxIndex+1];
-            if (true) {
-                // helpful debugging check
-                for (Field f: fields) {
-                    AllocationIndex index = f.getAnnotation(AllocationIndex.class);
-                    if (index != null) {
-                        int i = index.value();
-                        if (mBuffer[i] != 0) {
-                            throw new RuntimeException("@AllocationIndex on field in class "
-                                    + this.getClass().getName() + " with duplicate value "
-                                    + i + " for field " + f.getName() + ". The other field is "
-                                    + fields[mBuffer[i]-1].getName() + '.');
-                        }
-                        mBuffer[i] = i+1;
-                    }
-                }
-                for (int i=0; i<mBuffer.length; i++) {
-                    mBuffer[i] = 0;
-                }
-            }
-            mAlloc = Allocation.createSized(mRS, Element.USER_I32, mBuffer.length);
-        }
-        int[] buf = mBuffer;
-        for (Field f: fields) {
-            AllocationIndex index = f.getAnnotation(AllocationIndex.class);
-            if (index != null) {
-                try {
-                    buf[index.value()] = f.getInt(this);
-                } catch (IllegalAccessException ex) {
-                    throw new RuntimeException(ex);
-                }
-            }
-        }
-        mAlloc.data(buf);
-    }
-
-    public void read() {
-        int[] buf = mBuffer;
-        if (buf != null) {
-            mAlloc.readData(buf);
-            Field[] fields = this.getClass().getFields();
-            for (Field f: fields) {
-                AllocationIndex index = f.getAnnotation(AllocationIndex.class);
-                if (index != null) {
-                    try {
-                        f.setInt(this, buf[index.value()]);
-                    } catch (IllegalAccessException ex) {
-                        throw new RuntimeException(ex);
-                    }
-                }
-            }
-        }
-    }
-
-    Allocation getAllocation() {
-        return mAlloc;
-    }
-}
