small rearrangement

-make calculateMask a non class method.
-reorder some stuff in the header file.