Added the main functionality about masks and many stuff