I wouldn't really call it "done" just yet, since we have the issues below. There must be a much better way of allocating and using memory than these hacks.