Remove uses of ref and fix getindex so it is available from Base