Apply masks before history