Breaking out mask implementation into separate file.