Added docstrings. Changed bitmask specification. Minor fixes