added flatten_masks_stacks and updated __init__ to match