bugfix and simplification of flexible mask generation