Bug fix to get masks working