Adds documention

Adds documentation
Implements proper handling of MASK