Add perpetual code

@mortenvp @janusheide I will try to update this branch with the master. We should release perpetual NC soon.
Would be nice to also test the wrap around so with a buffer like:
```
[0000...000111111000...000]
```