Add level vs power_of_two checking. Move mod math to module..