Move all non-mask specific code to a sharable module,