Fixed bug with masks being discarded while saving.