Arrays for tam

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