Arrays for tam

- [x] Remove #redefine
- [x] Use reduce and replace/remove counter
- [x] Possibly rename a few functions