fixed bugs in categories. added docstrings.