Better fix for gradient slider. This replaces 5e57fafa0d78
Coverity CID 1034359
Fix multiple (potential?) memleaks in masks. Anything broken?
Coverity CID 1125109, CID 1125110, CID 1147481, CID 1147482, CID 1147483, CID 1147484, CID 1147485, CID 1147486, CID 1147487, CID 1147488, CID 1147489