Porting of modules

Can be simply replaced by:
```
//invert pos
pos = pos ^ 1;```