DISCL-235: Code review Friday refactorings

This is preliminary draft review
Haha I see that as a C++ programer you have optimization in mind, but pow() reads better than bit shifting for me.. :-)