Undefine index and rindex first to prevent clashes with tt funcs. Should be fixed by namespacing local funcs