Minor changes to replace mask implementation.