Finished implementation of categories
Fixes #4